﻿using StockTrader.Platform.Logging;
using System;
using StockTrader.Broker.IciciDirect;
using StockTrader.Core;
using StockTrader.Utilities;

namespace Experiments
{
    partial class Program
    {
        static void Main(string[] args)
        {
            //var n1 = RemoteUtils.IsNetworkAvailable();
            //var n2 = RemoteUtils.CheckPingResponse();
            //Console.WriteLine("IsNetworkAvailable={0}, CheckPingResponse={1}", n1, n2);

            //int days = -1;
            //if (args.Length > 0)
            //{
            //    if (int.TryParse(args[0], out days))
            //        days = -days;
            //}
            //CollateDayPartTickFiles(days);

            while (true) { Misc3(); }

            //MessagingUtils.Init(null, null);
            //MessagingUtils.SendAlertMessage("Test", "test", "", MessagingChannel.EMAIL);
            //Console.ReadLine();
        }


        static void Misc3()
        {
            var timeLapsed = DateTime.Now - DateTime.Now.AddMilliseconds(-1);

            Console.WriteLine(timeLapsed.TotalMilliseconds * 0.6 + "    " +  timeLapsed.Milliseconds);
        }

        static void Misc2()
        {
            var values = Enum.GetNames(typeof(RemoteCommand));

            var str = string.Join("\n", values);
            MessagingUtils.Init(null, null);
            MessagingUtils.SendAlertMessage("test", "Hiiiiiiiiiiii", "Hello", MessagingChannel.SMS);


            Console.ReadLine();
            IciciDirectBroker _iciciDirectAccount = new IciciDirectBroker("", "", "");

            EquitySymbolQuote[] infoE;
            _iciciDirectAccount.GetEquityQuote("RELIND", out infoE);
            DerivativeSymbolQuote infoD;
            _iciciDirectAccount.GetDerivativeQuote("RELIND", InstrumentType.FutureStock,
                MarketUtils.GetExpiryExactDate(new DateTime(2013, 03, 28)), 740, out infoD);


            var data = HttpLibrary.HttpHelper.GetWebPageResponse("https://secure.icicidirect.com/NewSiteTrading/Trading/fno/Includes/StockList.asp",
                null, null, new System.Net.CookieContainer());

            //var data = _iciciDirectAccount.IciciGetWebPageResponse(
        }
        static void Misc()
        {
            //int days = 0;
            //if (args.Length > 0)
            //{
            //    if (int.TryParse(args[0], out days))
            //        days = -days;
            //}
            //CollateDayPartTickFiles(days);
            //CleanseTickFiles();
            //GetRealTimeData1d();
            //ConvertGoogleFormatToMine();

            //PlayWithMail();

            //PlayWithGtalk();

            //MessagingUtils.SendEmail("test", "test");

            //try
            //{
            //    //var data = HttpHelper.GetWebPageResponse("http://google.com", null, null, new System.Net.CookieContainer());
            //    //var isNetwork = RemoteUtils.IsNetworkAvailable();
            //    int tries = 0;
            //    do
            //    {
            //        var isNetworkAvailable = RemoteUtils.IsNetworkAvailable() && RemoteUtils.CheckPingResponse();
            //        Thread.Sleep(1000);
            //    }
            //    while (tries++ < 10);
            //}
            //catch 
            //{ 

            //}

            //PlayWithSms();
        }

        static void PlayWithSms()
        {
            MessagingUtils.Init(null, null);
            MessagingUtils.SendAlertMessage("hi", "test", "test-SMS", MessagingChannel.SMS);
        }
    }
}
